import QtQuick 1.1
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"

Rectangle {
  property variant modelManager 
  color : 'black'
  height : 500
  width : 700
  id:mainRect
  focus:true
  onFocusChanged : {
    console.log('mainRect focus:' + focus);
    if(focus){
      diapoTimer.start();
    }else{
      diapoTimer.stop();
    }
  }
  
  Timer {
      id:diapoTimer
      interval: 5000; 
      repeat: true
      onTriggered: {
	//console.log('suite model=>' + modelManager.modelName);
	listV.incrementCurrentIndex();
      }
  }
      
      
  //DirectoryModel {
  /*PhotoModel{
    id : modelManager
    //Component.onCompleted : loadLocalModel('/home/manu/Images');
    //Component.onCompleted : loadPicasaAlbum('https://picasaweb.google.com/data/feed/base/user/112103620701242175348?alt=atom&kind=photo&hl=fr&access=public');
  }*/
  
    
Component {
    id : delegate
    Item {
      height : mainRect.height
      width : mainRect.width
      id:mainItem
      scale: 0.3
      transform: Rotation { id:rotation; origin.x: 0; origin.y: 0; angle: -45}
      
      Timer {
	  id:timer
	  interval: 200; 
	  running: false; 
	  repeat: false;
	  onTriggered : mainItem.state = 'viewing';
      }
      states: [
	  State {
	    name: 'viewing'; //when : activeFocus
	    PropertyChanges { target: mainItem;scale: 1}
	    PropertyChanges { target: rotation;angle:0}
	     PropertyChanges { target: img;anchors.fill : parent}
	  }
	  ,State {
	    name: 'beforeActive'; 
	    PropertyChanges { target: mainItem;scale: 0.3}
	    PropertyChanges { target: rotation;angle:-45}
	  }
      ]
      transitions: Transition {
	    to:'*'
	    NumberAnimation { properties: "scale"; duration: 300 }
	    NumberAnimation { properties: "angle"; duration: 300 }
      }
	
      onFocusChanged:{
	  if(focus){timer.start();}
	  else state='';
      }
      
      Image{
	      id:img
	      fillMode: Image.PreserveAspectFit
	      anchors.left : parent.right
	      smooth : true
	      source:url
	  }
      }
    }    
    
    
    

    ListView {
      id:listV
      anchors.fill : parent
      model: modelManager.model
      orientation : ListView.Horizontal
      spacing: 40
      focus:false
      onFocusChanged : console.log('listV getFocus:' + focus);
      snapMode:ListView.SnapOneItem
      delegate: delegate
      highlightMoveDuration:100
      onCurrentIndexChanged: modelManager.indexChanged(currentIndex);
     }
	
}
